package top.i89ck;

import com.jfinal.config.Constants;
import com.jfinal.config.Routes;
import com.jfinal.core.JFinal;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.template.Engine;
import org.opensource.jfhelper.props.JFinalProp;
import org.opensource.jfhelper.utils.Const;
import org.opensource.jfhelper.utils.YmlKit;
import top.i89ck.common.jqgrid.JqGridInterceptor;
import top.i89ck.common.jqgrid.JqGridShared;
import top.i89ck.common.utils.App;
import top.i89ck.modules.handler.GlobalInterceptor;
import top.i89ck.modules.handler.LoginInterceptor;
import top.i89ck.modules.model._MappingKit;
import org.opensource.jfhelper.JfHelper;

/**
 * 项目运行包
 * @author liyingfu
 */
public class AppStart extends JfHelper {

    @Override
    public void addMappingKit(ActiveRecordPlugin arp) {
        _MappingKit.mapping(arp);
    }

    @Override
    public void configEngine(Engine engine) {
        super.configEngine(engine);
        App app = YmlKit.toBean(App.class, "jFinal");
        System.out.println("项目的名字" + app.getName());
        engine.addSharedObject("appName", app.getName());
        new JqGridShared(engine);
    }

    @Override
    public void configRoute(Routes routes) {
        super.configRoute(routes);
        routes.addInterceptor(new GlobalInterceptor());
        routes.addInterceptor(new LoginInterceptor());
        routes.addInterceptor(new JqGridInterceptor());
    }

    public static void main(String[] args) {
        JFinal.start("src/main/webapp", 8080, "/", 5);
    }
}
